//根据运单编号，获取运单信息
function getWaybillInfoByNum(waybillNum,isSearch) {
    if (waybillNum != null && waybillNum != '') {
        //运单号校验
        var waybillInfoFormValidate =true;
        if(isSearch){
            waybillInfoFormValidate = $("#csWoCustSerDetail"+" #waybillInfoForm").form('validate');
        }
        if(waybillInfoFormValidate) {
            //调用接口获取运单信息
            uceAjax(G_CTX_PATH + '/cs/CsCommon/findWaybllInfo.do',{billCode:waybillNum},function (result){
                //本地模拟
                // uceAjax(G_CTX_PATH + '/cs/CsWoCustSer/findWaybllInfo.do', {billCode: waybillNum}, function (result) {
                if(result.data){
                    //运单信息赋值
                    $("#waybillInfoForm #waybillNum").textbox("setValue", waybillNum);
                    $("#waybillInfoForm #hairPiece").textbox("setValue", result.data.sendOrgName);
                    $("#waybillInfoForm #addresser").textbox("setValue", result.data.sender);
                    $("#waybillInfoForm #addressPhone").textbox("setValue", result.data.senderTel);
                    $("#waybillInfoForm #hairAddress").textbox("setValue", result.data.senderAddress);
                    $("#waybillInfoForm #recipient").textbox("setValue", result.data.receiver);
                    $("#waybillInfoForm #recipientPhone").textbox("setValue", result.data.receiverTel);
                    $("#waybillInfoForm #recipientAddress").textbox("setValue", result.data.receiverAddress);
                    $("#waybillInfoForm #internalGoods").textbox("setValue", result.data.goodsName);

                    //初始化发件地址省、市、区、乡镇2018-07-02
                    var sendParams={editable:false,
                        provinceValue:result.data.sendProvinceCode,
                        cityValue:result.data.sendCityCode,
                        regionValue:result.data.sendCountyCode
                    };
                    pcrtAreaCascade("sendProvince","sendCity","sendArea","sendTown",sendParams);
                    if(result.data.sendProvinceCode){
                        $("#waybillInfoForm #sendProvince").combobox('readonly',true);
                    }else{
                        $("#waybillInfoForm #sendProvince").combobox('readonly',false);
                    }
                    if(result.data.sendProvinceCode && result.data.sendCityCode){
                        $("#waybillInfoForm #sendCity").combobox('readonly',true);
                    }else{
                        $("#waybillInfoForm #sendCity").combobox('readonly',false);
                    }
                    if(result.data.sendProvinceCode && result.data.sendCityCode && result.data.sendCountyCode){
                        $("#waybillInfoForm #sendArea").combobox('readonly',true);
                    }else{
                        $("#waybillInfoForm #sendArea").combobox('readonly',false);
                    }

                    //发件详细地址
                    if(result.data.senderAddress){
                        $("#waybillInfoForm #sendAddress").textbox("setValue", result.data.senderAddress);
                        $("#waybillInfoForm #sendAddress").textbox('readonly',true);
                    }else{
                        $("#waybillInfoForm #sendAddress").textbox('readonly',false);
                    }

                    //收件人
                    if(result.data.receiver){
                        $("#waybillInfoForm #receiver").textbox("setValue", result.data.receiver);
                        $("#waybillInfoForm #receiver").textbox('readonly',true);
                    }else{
                        $("#waybillInfoForm #receiver").textbox('readonly',false);
                    }
                    //收件电话
                    if(result.data.receiverTel){

                        $("#waybillInfoForm #receiverTel").textbox("setValue", result.data.receiverTel);
                        $("#waybillInfoForm #receiverTel").textbox('readonly',true);

                        //设置验证属性
                        $("#waybillInfoForm #receiverTel").textbox({validType:""});
                        //解析指定元素
                        $.parser.parse($("#waybillInfoForm #receiverTel"));
                    }else{
                        $("#waybillInfoForm #receiverTel").textbox('readonly',false);
                        //设置验证属性
                        $("#waybillInfoForm #receiverTel").textbox({validType:"phoneNum"});
                        //解析指定元素
                        $.parser.parse($("#waybillInfoForm #receiverTel"));
                    }

                    //初始化收件地址省、市、区、乡镇 2018-07-02
                    var receiveParams={editable:false,
                        provinceValue:result.data.recProvinceCode,
                        cityValue:result.data.recCityCode,
                        regionValue:result.data.recCountyCode
                    };
                    pcrtAreaCascade("receiveProvince","receiveCity","receiveArea","receiveTown",receiveParams);
                    if(result.data.recProvinceCode){
                        $("#waybillInfoForm #receiveProvince").combobox('readonly',true);
                    }else{
                        $("#waybillInfoForm #receiveProvince").combobox('readonly',false);
                    }
                    if(result.data.recProvinceCode && result.data.recCityCode){
                        $("#waybillInfoForm #receiveCity").combobox('readonly',true);
                    }else{
                        $("#waybillInfoForm #receiveCity").combobox('readonly',false);
                    }
                    if(result.data.recProvinceCode && result.data.recCityCode && result.data.recCountyCode){
                        $("#waybillInfoForm #receiveArea").combobox('readonly',true);
                    }else{
                        $("#waybillInfoForm #receiveArea").combobox('readonly',false);
                    }
                    if(result.data.receiverAddress){
                        $("#waybillInfoForm #receiveAddress").textbox("setValue", result.data.receiverAddress);
                        $("#waybillInfoForm #receiveAddress").textbox('readonly',true);
                    }else{
                        $("#waybillInfoForm #receiveAddress").textbox('readonly',false);
                    }

                    //工单表单运单编号隐藏域赋值
                    // $("#waybillInfoForm [name='waybillNum']").val(waybillNum);

                    logisticsInformationListLoadings(waybillNum);

                }else{
                    showInfoMsg("运单号不存在");
                }
            }, "GET");
        }else{
            showInfoMsg("请输入正确的运单号");
        }
    }
}

function  logisticsInformationListLoadings(value){

    var columns = [[
        {field:'createDate',title: '日期',width: 180,align: 'center'},
        {field:'createTime',title: '时间',width: 180,align: 'center'},
        {field:'trackMessage',title: '跟踪记录',width: 737}
    ]]
    var dataGridParams = {
        url:G_CTX_PATH+"/cs/HomeScreenPopup/findTraceInfo.do",
        Method:'POST',
        queryParams:{billCode:value},
        singleSelect : 'true',
        fitColumns : 'false',
        rownumbers: 'false'
    }
    newloadGrid('logisticsInformationList', columns, dataGridParams);
}